import { _decorator, Component, Node, Sprite, resources, SpriteFrame, UITransform, Layers } from 'cc'
const { ccclass, property } = _decorator


import { IIile, ILevel } from '../Levels'
import Singleton from '../Base/Singleton'

// 实现单例
export default class RescourceManager extends Singleton {
  tileREsources: Map<string, IIile> = new Map()

  static get Instance() {
    return super.getInstance<RescourceManager>()
  }

  loadDir(path: string, type: typeof SpriteFrame = SpriteFrame) {
    return new Promise<SpriteFrame[]>((resolve, reject) => {
      // 加载图片资源
      resources.loadDir(path, type, function (err, assets) {
        if (err) {
          reject(err)
        } else {
          resolve(assets as SpriteFrame[])
        }
      })
    })
  }
}

